package cn.cdeden.knowledge.domain;


import cn.cdeden.common.core.utils.MapstructUtils;
import cn.cdeden.knowledge.api.domain.vo.RemoteTeamFilesTreeVo;
import cn.cdeden.knowledge.domain.dto.FilesTree;
import cn.cdeden.knowledge.domain.dto.TeamFilesTreeDto;
import cn.cdeden.knowledge.domain.dto.TeamToEnterpriseDto;
import cn.cdeden.knowledge.domain.vo.FilesTreeRecycleVo;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import com.baomidou.mybatisplus.annotation.*;
import io.github.linpeilie.annotations.AutoMapper;
import io.github.linpeilie.annotations.AutoMappers;
import lombok.*;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.util.Date;

/**
* @author Chen
* @date 2022-09-16
*/
@Data
@Builder
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
@AutoMappers({@AutoMapper(target = TeamFilesTreeDto.class),@AutoMapper(target = FilesTree.class),@AutoMapper(target = TeamFilesTree.class),@AutoMapper(target = FilesTreeRecycleVo.class),@AutoMapper(target = FilesTreeRecycle.class),@AutoMapper(target = TeamToEnterpriseDto.class),@AutoMapper(target = RemoteTeamFilesTreeVo.class)})
@TableName("team_files_tree")
public class TeamFilesTree implements Serializable {
    private static final long serialVersionUID = 1L;

//    @ApiModelProperty(value = "编号")
    @TableId(type= IdType.AUTO)
    private Long id;

//    @ApiModelProperty(value = "父亲编号")
    private String parentId;

//    @ApiModelProperty(value = "团队编号")
    private String teamId;

//    @ApiModelProperty(value = "后缀名")
    private String suffix;

//    @ApiModelProperty(value = "名称")
    private String realName;

//    @ApiModelProperty(value = "上级路径")
    private String superiorsPath;

//    @ApiModelProperty(value = "路径")
    private String path;

//    @ApiModelProperty(value = "类型")
    private String type;

//    @ApiModelProperty(value = "储存表id")
    private String storageId;

//    @ApiModelProperty(value = "储存服务器类型")
    private String storageType;

//    @ApiModelProperty(value = "文件大小")
    private Long size;

//    @ApiModelProperty(value = "关连状态")
    private String linkingState;

//    @ApiModelProperty(value = "收藏")
    private String collection;

//    @ApiModelProperty(value = "关注")
    private String attention;

//    @ApiModelProperty(value = "锁定")
    private String isLock;


//    @ApiModelProperty(value = "删除 是否可以被查询")
    private String deleteType;

//    @ApiModelProperty(value = "版本号")
    private String editionName;

//    @ApiModelProperty(value = "版本编码")
    private String edition;

//    @ApiModelProperty(value = "标记tms资源")
    private String toTms;

//    @ApiModelProperty(value = "备注")
    private String remarks;

//    @ApiModelProperty(value = "创建编号")
    @TableField(fill= FieldFill.INSERT)
    private String createId;

//    @ApiModelProperty(value = "创建者")
    @TableField(fill= FieldFill.INSERT)
    private String createBy;

//    @ApiModelProperty(value = "创建日期")
    @TableField(fill= FieldFill.INSERT)
    private Date createTime;

//    @ApiModelProperty(value = "更新编号")
    @TableField(fill= FieldFill.INSERT_UPDATE)
    private String updateId;

//    @ApiModelProperty(value = "更新者")
    @TableField(fill= FieldFill.INSERT_UPDATE)
    private String updateBy;

//    @ApiModelProperty(value = "更新时间")
    @TableField(fill= FieldFill.INSERT_UPDATE)
    private Date updateTime;

//    @ApiModelProperty(value = "删除编号")
    private String deleteId;

//    @ApiModelProperty(value = "删除者")
    private String deleteBy;

//    @ApiModelProperty(value = "删除时间")
    private Date deleteTime;

    @TableField(updateStrategy = FieldStrategy.IGNORED)
//    @ApiModelProperty(value = "生效日期")
    private Date effectiveDate;

    @TableField(updateStrategy = FieldStrategy.IGNORED)
//    @ApiModelProperty(value = "过期日期")
    private Date expirationDate;

//    @ApiModelProperty(value = "项目模板")
    private String templateName;

//    @ApiModelProperty(value = "文档内容")
    private String docContent;

    @TableField(value = "es_id")
    private String esId;

//    @ApiModelProperty(value = "置顶")
    private Integer sort;


    public void copyFrom(TeamFilesTree source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }

    public TeamFilesTree(String createId, String createBy) {
        this.createId = createId;
        this.createBy = createBy;
        this.createTime = new Date();
        this.updateId = createId;
        this.updateBy = createBy;
        this.updateTime = new Date();


    }

    public TeamFilesTree filesCopy(String createId, String createBy) {
        TeamFilesTree tree = MapstructUtils.convert(this, TeamFilesTree.class);
        tree.setId(null);
        tree.setTeamId(null);
        tree.setCreateId(createId);
        tree.setCreateBy(createBy);
        tree.setCreateTime( new Date());
        tree.setUpdateId(null);
        tree.setUpdateBy(null);
        tree.setUpdateTime(null);
        return tree ;
    }
}
